package cn.powerone.scm.mapper;

import java.util.Date;
import java.util.List;
import cn.powerone.scm.domain.ScmSupplier;
import cn.powerone.scm.domain.ScmSupplierContacts;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

/**
 * 供应商Mapper接口
 * 
 * @author PowerOne
 * @date 2025-06-23
 */
public interface ScmSupplierMapper 
{
    /**
     * 查询供应商
     * 
     * @param id 供应商主键
     * @return 供应商
     */
    public ScmSupplier selectScmSupplierById(Long id);

    /**
     * 查询供应商列表
     * 
     * @param scmSupplier 供应商
     * @return 供应商集合
     */
    public List<ScmSupplier> selectScmSupplierList(ScmSupplier scmSupplier);

    /**
     * 新增供应商
     * 
     * @param scmSupplier 供应商
     * @return 结果
     */
    public int insertScmSupplier(ScmSupplier scmSupplier);

    /**
     * 修改供应商
     * 
     * @param scmSupplier 供应商
     * @return 结果
     */
    public int updateScmSupplier(ScmSupplier scmSupplier);

    /**
     * 删除供应商
     * 
     * @param id 供应商主键
     * @return 结果
     */
    public int deleteScmSupplierById(Long id);

    /**
     * 批量删除供应商
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteScmSupplierByIds(Long[] ids);

    /**
     * 批量删除供应商联系人
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteScmSupplierContactsBySupplierIds(Long[] ids);
    
    /**
     * 批量新增供应商联系人
     * 
     * @param scmSupplierContactsList 供应商联系人列表
     * @return 结果
     */
    public int batchScmSupplierContacts(List<ScmSupplierContacts> scmSupplierContactsList);
    

    /**
     * 通过供应商主键删除供应商联系人信息
     * 
     * @param id 供应商ID
     * @return 结果
     */
    public int deleteScmSupplierContactsBySupplierId(Long id);

    @Select("SELECT COUNT(*) FROM scm_supplier WHERE YEAR(create_time) = YEAR(#{yesterday}) AND MONTH(create_time) = MONTH(#{yesterday})")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierCountByMonth(Date yesterday);

    @Select("SELECT COUNT(*) FROM scm_supplier WHERE YEAR(create_time) = YEAR(#{yesterday})")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierCountByYear(Date yesterday);

    @Select("SELECT COUNT(*) FROM scm_supplier")
    @Options(useCache = false, flushCache = Options.FlushCachePolicy.TRUE)
    public int selectSupplierCountAll();
}
